// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import './scss/base.scss'
import './components'
import router from './routers'
import store from './store'
import { session } from 'js/util'

Vue.config.productionTip = false


router.beforeEach((to, from, next) => {
  if (to.meta.isAuth) {
    const userInfo = session.get('userInfo') || {}
    if (userInfo.token) {
      next()
    } else {
      next({
        path: '/login'
      })
    }
  } else {
    next()
  }
})

/* eslint-disable no-new */
export default new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
